package src.chapter02;

import java.util.Scanner;

public class Access01 {
    public static void main(String[] args) {
        int pencil = 1;
        int xp = 2;
        int kl = 3;
        int book = 12;
        int ls = 5;
        System.out.println("书本价格" + book + "元，你一共有20元");
        System.out.println("1.铅笔价格" + pencil + "元");
        System.out.println("2.橡皮价格" + xp + "元");
        System.out.println("3.可乐价格" + kl + "元");
        System.out.println("4.零食价格" + ls + "元");
        Scanner scl = new Scanner(System.in);
        System.out.println("输入商品序列号：");
        int id = scl.nextInt();
        switch (id) {
            case 1:
                int pencilmoney = 20 - book;
                int pencilsum = pencilmoney / pencil;
                int pencilsurplus = pencilmoney % pencil;
                System.out.println("购买完书本后还可以购买铅笔" + pencilsum + "个，还剩" + pencilsurplus + "元");
                break;
            case 2:
                int rubbermoney = 20 - book;
                int rubbersum = rubbermoney / xp;
                int rubbersurplus = rubbermoney % xp;
                System.out.println("购买完书本后还可以购买橡皮" + rubbersum + "个，还剩" + rubbersurplus + "元");
                break;
            case 3:
                int colamoney = 20 - book;
                int colasum = colamoney / kl;
                int colasurplus = colamoney % kl;
                System.out.println("购买完书本后还可以购买可乐" + colasum + "个，还剩" + colasurplus + "元");
                break;
            case 4:
                int snacksmoney = 20 - book;
                int snackssum = snacksmoney / ls;
                int snackssurplus = snacksmoney % ls;
                System.out.println("购买完书本后还可以购买零食" + snackssum + "个，还剩" + snackssurplus + "元");
                break;
            default:
                System.out.println("您的输入有误。");
                break;

        }
    }
}
